# @Time : 2020/7/27 14:50
# @Author : Fioman 
# @Phone : 13149920693

"""
先腐蚀后膨胀就是开运算.
开运算可以用来去除噪声和计数等.
腐蚀膨胀 还可以将两个连接的物体分开.
opening = cv.morphologyEx(img,cv.MORPH_OPEN,kernel)
"""
import cv2 as cv
import numpy as np

img1 = cv.imread("open1.jpg",cv.IMREAD_GRAYSCALE)
img2 = cv.imread("open2.jpg",cv.IMREAD_GRAYSCALE)

kernel = np.ones((5,5),dtype=np.uint8)
opened1 = cv.morphologyEx(img1,cv.MORPH_OPEN,kernel,iterations=1)
opened2 = cv.morphologyEx(img2,cv.MORPH_OPEN,kernel,iterations=1)

cv.imshow("Original1",img1)
cv.imshow("Original2",img2)
cv.imshow("Opened1",opened1)
cv.imshow("Opened2",opened2)

cv.waitKey(0)
cv.destroyAllWindows()

